import Vue from 'vue'
import VueRouter, { RawLocation, RouteConfig } from 'vue-router'
import Index from '../views/Index.vue'
import Blog from '../views/main/Blog.vue'
import Brand from '../views/main/Brand.vue'
import EventAndNews from '../views/main/EventAndNews.vue'
import Hot from '../views/main/Hot.vue'
import Login from '../views/main/Login.vue'
import Picture from '../views/main/Picture.vue'
import ShopList from '../views/main/ShopList.vue'
import EventAndNewsList from '../components/eventAndNews/EventAndNewsList.vue'
import EventAndNewsDetail from '../components/eventAndNews/EventAndNewsDetail.vue'
import BrandList from '../components/brand/BrandList.vue'
import BrandDetail from '../components/brand/BrandDetail.vue'
import SmsLogin from '../components/user/SmsLogin.vue'
import UsernameLogin from '../components/user/UsernameLogin.vue'
import User from '../components/user/User.vue'
import Oauth from '../components/user/Oauth.vue'
import ProductDetail from '../components/product/ProductDetail.vue'
import HelpCenter from '../components/others/HelpCenter.vue'
import PrivacyPolicy from '../components/others/PrivacyPolicy.vue'
import Contact from '../components/others/Contact.vue'
import Consultation from '../components/others/Consultation.vue'
import Introduce from '../components/others/Introduce.vue'
import UserInformation from '../components/user/UserInformation.vue'

Vue.use(VueRouter)

const routes: Array<RouteConfig> = [
  {
    path: '/',
    name: 'Index',
    component: Index
  },
  {
    path: '/index',
    component: Index
  },
  {
    path: '/oauth',
    name: 'Oauth',
    components: {
      oauth: Oauth
    }
  },
  {
    path: '/blog',
    name: 'Blog',
    component: Blog
  },
  {
    path: '/brand',
    component: Brand,
    children: [
      {
        path: '/',
        name: 'defaultBrandList',
        component: BrandList
      },
      {
        path: 'brandDetail',
        name: 'brandList',
        component: BrandDetail
      }
    ]
  },
  {
    path: '/eventAndNews',
    component: EventAndNews,
    children: [
      {
        path: '/',
        name: 'defaultEventAndNewsList',
        component: EventAndNewsList
      },
      {
        path: 'eventAndNewsDetail/:id',
        name: 'eventAndNewsDetail',
        component: EventAndNewsDetail,
        props: true
      }
    ]
  },
  {
    path: '/hot',
    name: 'Hot',
    component: Hot
  },
  {
    path: '/hot/detail/:id',
    name: 'ProductDetail',
    component: ProductDetail,
    props: true
  },
  {
    path: '/picture',
    name: 'Picture',
    component: Picture
  },
  {
    path: '/shopList',
    name: 'ShopList',
    component: ShopList
  },
  {
    path: '/login',
    component: Login,
    children: [
      {
        path: '/',
        name: 'defaultSmsLogin',
        component: SmsLogin
      },
      {
        path: 'sms_login',
        name: 'smsLogin',
        component: SmsLogin
      },
      {
        path: 'username_login',
        name: 'usernameLogin',
        component: UsernameLogin
      }
    ]
  },
  {
    path: '/user',
    component: User,
    children: [
      {
        path: '',
        component: UserInformation
      },
      {
        path: 'userInformation',
        component: UserInformation
      }
    ]
  },
  {
    path: '/other',
    component: HelpCenter,
    children: [
      {
        path: '',
        component: PrivacyPolicy
      },
      {
        path: 'privacyPolicy',
        component: PrivacyPolicy
      },
      {
        path: 'contact',
        component: Contact
      },
      {
        path: 'introduce',
        component: Introduce
      },
      {
        path: 'consultation',
        component: Consultation
      }
    ]
  }
  // {
  //   path: '/about',
  //   name: 'In',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
